import axios from './request'

//封装接口

//注册接口
function register(params = {}){
    return axios.post('/api/user/register', params )
}

//登录接口
function login(params = {}){
    return axios.post('/api/user/login', params )
}

//轮播图接口
function swiper(params = {}){
    return axios.get('/api/index/banner',{params})
}

//首页:导航接口
function nav(params = {}){
    return axios.get('/api/index/nav',{params})
}

//推荐接口
function recommend(params = {}){
    return axios.get('/api/index/goodlist',{params})
}

//一级分类接口
function category(params = {}){
    return axios.get('/api/category/list',{params})
}

//二三级接口
function secondCategory(params = {}){
    return axios.get('/api/category/subcate',{params})
}
//按分类查找
function categoods(params = {}){
    return axios.get('/api/good/list',{params})
}
//商品详情
function gooddetalis(params = {}){
    return axios.get('/api/good/goodinfo',{params})
}

//点击收藏
function collectgoods(params = {}){
    return axios.post('/api/good/fav',params)
}

//收藏列表
function collectlist(params = {}){
    return axios.get('/api/good/favlist',{params})
}

//取消收藏
function canclecollect(params = {}){
    return axios.post('/api/good/unfav',params)
}

//购物车数量加一
function addShopcart(params = {}){
    return axios.post('/api/shopcart/add',params)
}

//购物车数量减一
function subShopcart(params = {}){
    return axios.post('/api/shopcart/sub',params)
}

//购物车列表
function shopcartlist(params = {}){
    return axios.get('/api/shopcart/list',{params})
}

//清空购物车
function clearShopcart(params = {}){
    return axios.post('/api/shopcart/clear',params)
}

//搜索
function search(params = {}){
    return axios.get('/api/good/search',{params})
}

export {
    register,
    login,
    swiper,
    nav,
    recommend,
    category,
    secondCategory,
    categoods,
    gooddetalis,
    collectgoods,
    collectlist,
    canclecollect,
    addShopcart,
    shopcartlist,
    clearShopcart,
    subShopcart,
    search
}